package com.hs.Compiler;

import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import java.io.*;

/**
 * @Author: hs
 * @Description:
 * @Date: Create in 11:36 2019/9/4
 */
public class MyCompliler {
    public static void main(String[] args) throws Exception {
        String javaPath ="C:\\Users\\Administrator\\Desktop\\java\\A.java";
        //FileInputStream fileInputStream = new FileInputStream(javaPath);
        OutputStream outputStream = new ByteArrayOutputStream();
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        compiler.run(null, null, null, "-encoding", "UTF-8","-classpath",javaPath,javaPath);
        byte[] b = new byte[1204];
        outputStream.write(b);
        System.out.println(new String(b));
    }
}
